(function($f) { $f.extend.app("5f70f2dc-baeb-40f1-a335-ed6e05ee82f4", function(self) {

	"use strict";

	// plugin info
	this.info = {
		// title of the plugin
		title: "My Application",
		version: "0.0.1", // major.minor.build
		description: "This is my application."
	};

	// plugin entries in session (contents here-in must be JSON serializable)
	// if items are defined here, these will be maintained in session
	// items must be defined here with their initial value - it will be replaced with an object
	// at runtime which can be accessed as:
	// this.session.<name>.get() to get it, this.session.<name>.set(<value>) to set it
	this.session = { 
		appVar1: 1,		
		appVar2: Date.now(),
		appVar3: "app String",
		appVar4: false
	};

	// on after navigation is completed and everything is ready 
	// and focus is set on main screen this is last place in 
	// navigation cycle
	// returns (void):
	this.onReadyAll = function() { 
		// show session state
		self.showSessionState();
		
		// show list
		self.sessionItemsList();
	};
	
	// show session state
	this.showSessionState = function() {
		$("#sessionState").html("<p><strong>Session state:</strong> " + ($f.sess.isNew.get() ? "New (no page refresh since start)" : "Old (page refreshed since start)")).append("<strong>Started at:</strong> " + $f.sess.startedAt.get().toString());
	};
	
	// check to session
	this.checkInSession = function() {
		// read from UI
		var name = $("#sessionVariableName")[0].value;
		
		// check in session and write
		$("#isSessionVariableAvailable")[0].value = ($f.sess.has(name) ? "Yes" : "No");
	};
	
	// write to session
	this.writeToSession = function() {
		// read from UI
		var name = $("#sessionVariableName")[0].value;
		var value = $("#sessionVariableDefinedValue")[0].value;
		
		// write to session
		$f.sess.set(name, value);
		
		// show list
		self.sessionItemsList();
	};

	// remove from session
	this.removeFromSession = function() {
		// read from UI
		var name = $("#sessionVariableName")[0].value;
		
		// remove from session
		$f.sess.set(name, null);
		
		// show list
		self.sessionItemsList();
	};
	
	// read from session
	this.readFromSession = function() {
		// read from session
		var name = $("#sessionVariableName")[0].value;
		var value = $f.sess.get(name, "(not found)");
		
		// write to UI
		$("#sessionVariableReadValue")[0].value = value;
	};
	
	// clear
	this.clearSession = function() {
		// clear session
		$f.sess.clear();
		
		// show session state
		self.showSessionState();
		
		// show list
		self.sessionItemsList();
	};
	
	// show list
	this.sessionItemsList = function() {
		var div = $("#sessionItems");
		
		// session items list
		var count = "Total " + $f.sess.count().toString() + " items.<br /><br />";
		var list = "<table class='table table-bordered'><tr><th align='left'>Name</th><th align='left'>Value</th></tr>";
		$.each($f.sess.items(), function(i, item) {
			list += "<tr><td style='vertical-align: top'>" + item + 
					"</td><td>" + $f.sess.get(item, "(not found)").toString() + 
					"</td></tr>";
		});
		list += "</table>";
		div.empty().append(count + list);		
	};
}); }(fluid));